﻿#ifndef MEASUREPOLYGON_H
#define MEASUREPOLYGON_H


#include "MeasureElement.h"
namespace Qly {

class MeasureDataSet;

/**
 * @brief The MeasurePolygon class 多边形的长度和面积
 *           m_results_um[0] 多边型的边长
 *           m_results_um[1] 面积
 *
 *           textTemplate 支持 @length_um, @length_mm, @length, @unit,
 *                             @area_um2, @area_mm2, @area, @areaUnit, @id 9 个关键字
 */
class MeasurePolygon : public MeasureElement
{
    friend MeasureDataSet;
public:
    MeasurePolygon(MeasureDataSet *parent = nullptr);
    QString name() Q_DECL_OVERRIDE {return u8"多边形面积";}
private:
    int mouseLButtonPress(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;
    int mouseRButtonPress(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;
    int mouseMove(QPointF point_pix, QPointF point_um) Q_DECL_OVERRIDE;

    void setStartPoint(QPointF point_pix, QPointF point_um);
    void setMidPoint(QPointF point_pix, QPointF point_um);
    void setTempEndPoint(QPointF point_pix, QPointF point_um);
    void setEndPoint(QPointF point_pix, QPointF point_um);
    void compute(void) Q_DECL_OVERRIDE; //计算图元的位置，还有长度结果
    void updateText(bool updatePosition = true) Q_DECL_OVERRIDE;
    void paint( QPainter &painter ) Q_DECL_OVERRIDE; //画方法

    QPointF m_tempEnd_um;
    QPointF m_tempEnd_pix;
};

}
#endif // MEASUREPOLYGON_H
